<template>
  <div>
    <a-card :bordered='false'>
      <f-search-form :more='true' @searchHandler='searchHandler' :tableObj='tableObj' :show-export-btn='true' :exportUrl='api.erpSearch.exportProcureList'>
        <f-search-form-item label='单据日期' type='range' name='beginDate' />
        <f-search-form-item label='单位名称' name='customNo' type='select' :data='api.erpSearch.selectHyCustomList' :params='queryParam' value-key='customNo' label-key='customName' :show-all='false' :show-search='true' />
        <f-search-form-item label='部门名称' name='deptNo' type='select' :data='api.erpSearch.selectHyDeptList' :params='queryParam' value-key='deptNo' label-key='deptName' />
        <f-search-form-item slot='advanced' label='批号' name='lotNo' />
        <f-search-form-item slot='advanced' label='单据编码' name='procureNo' />
        <f-search-form-item slot='advanced' label='业务员' name='saleManBusinessNo' />
        <f-search-form-item slot='advanced' label='制单人' name='userName' />
      </f-search-form>
      <f-table ref='table' rowKey='procureNo' :showSetting='true' :tableColumns='columns' :multiple='false' :operator='operator' :params='queryParam' :api='api.erpSearch.procureList' handler='exportListHandler'>
        <span slot='procureType' slot-scope='text, record'>
          <template>
              <a-tag v-if='text=="CKA"'>销售出库</a-tag>
              <a-tag v-if='text=="CKJ"'>销售退回</a-tag>
              <a-tag v-if='text=="CKI"'>退补差价</a-tag>
              <a-tag v-if='text=="CKB"'>调拨出库</a-tag>
              <a-tag v-if='text=="CKG"'>其他出库</a-tag>
              <a-tag v-if='text=="CKF"'>移出出库</a-tag>
              <a-tag v-if='text=="CKL"'>领用出库</a-tag>
              <a-tag v-if='text=="CKE"'>赠品出库</a-tag>
              <a-tag v-if='text=="CKC"'>报损出库</a-tag>
              <a-tag v-if='text=="CKD"'>盘亏出库</a-tag>
    
              <a-tag v-if='text=="RKB"'>采购验收</a-tag>
              <a-tag v-if='text=="RKN"'>进货退出</a-tag>
              <a-tag v-if='text=="RKM"'>退补差价</a-tag>
              <a-tag v-if='text=="RKF"'>商品损溢</a-tag>
              <a-tag v-if='text=="RKI"'>报升入库</a-tag>
              <a-tag v-if='text=="RKD"'>盘盈入库</a-tag>
              <a-tag v-if='text=="RKA"'>期初入库</a-tag>
          </template>
      </span>
        <span slot='action' slot-scope='text, record'>
          <template>
             <a @click='$refs.detailsDrawer.showDrawer(record)'>查看</a>
          </template>
       </span>
      </f-table>
    </a-card>
    <procure-details-drawer ref='detailsDrawer'></procure-details-drawer>
  </div>
</template>
<script>
import api from "./../../js/api"
import ProcureDetailsDrawer from "./procure_details_drawer"

export default {
  name: "MingXiList",
  components: { ProcureDetailsDrawer },
  data() {
    let me = this
    //操作按钮
    let operator = []
    let customFlag = this.$store.state.user.customFlag
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {
        companyId: this.$store.state.user.companyId
      },
      tableObj: null,
      superAdmin: this.superAdmin,
      // 表头
      columns: [
        {
          title: "序号",
          width: "70px",
          align: "center",
          customRender: (text, record, index) => index + 1
        },
        {
          title: "单据日期",
          align: "left",
          width: "80px",
          dataIndex: "procureDate"
        },
        {
          title: "单据编码",
          align: "left",
          width: "100px",
          dataIndex: "procureNo",
          scopedSlots: { customRender: "procureNo" }
        },
        {
          title: "单位名称",
          align: "left",
          width: "180px",
          dataIndex: "customName"
        },
        {
          title: "方式名称",
          align: "left",
          width: "80px",
          dataIndex: "procureType",
          scopedSlots: { customRender: "procureType" }
        },
        {
          title: "部门名称",
          align: "left",
          width: "80px",
          dataIndex: "deptName"
        },
        {
          title: "业务员",
          align: "left",
          width: "90px",
          dataIndex: "saleManName"
        },

        {
          title: "制单人",
          align: "left",
          width: "100px",
          dataIndex: "userName"
        },
        {
          title: "合计数量",
          align: "left",
          width: "100px",
          dataIndex: "procureNum"
        },
        {
          title: "合计无税成本",
          align: "left",
          width: "75px",
          isStatistics: true,
          dataIndex: "noTaxAmount"
        },
        {
          title: "备注",
          align: "left",
          width: "70px",
          dataIndex: "remark"
        },
        {
          title: "操作",
          align: "center",
          dataIndex: "action",
          width: "60px",
          scopedSlots: { customRender: "action" }
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  mounted() {
    this.tableObj = this.$refs.table
  },
  methods: {
    onCopy() {
      this.$message.success("复制成功!")
    },
    initSettle(record) {

    },
    clearExport() {
      this.http.post(this, {
        url: this.api.bod.clearExportData
      })
    }
  }
}
</script>
